﻿using EnvDTE;

namespace SmartStringResources.Dte
{
	public static class ProjectExtensions
	{
		public static string GetRootNamespace(this Project project)
		{
			if (project.GetLanguage() == Languages.VisualBasic)
				return project.Properties.GetPropertyValue("RootNamespace");

			return null;
		}

		public static ProjectItem GetProjectItemByFullPath(this Project project, string fullPath)
		{
			return project.ProjectItems.GetProjectItemByFullPath(fullPath);
		}

		public static string GetLanguage(this Project project)
		{
			if (project == null)
				return null;

			switch (project.CodeModel.Language)
			{
				case CodeModelLanguageConstants.vsCMLanguageMC:
				case CodeModelLanguageConstants.vsCMLanguageVC:
					return Languages.Cpp;
				case CodeModelLanguageConstants.vsCMLanguageVB:
					return Languages.VisualBasic;
				case "{E6FDF8BF-F3D1-11D4-8576-0002A516ECE8}":
					return Languages.JScript;
				case CodeModelLanguageConstants.vsCMLanguageCSharp:
				default:
					return Languages.CSharp;
			}
		}

	}
}
